'''
''' Override the DeleteButton_Click() button handler method. Add custom logic that gets executed
''' on ${Button Control}_Click
'''
Public Overrides Sub ${Button Control}_Click(ByVal sender As Object, ByVal args As System.Web.UI.ImageClickEventArgs)
Try
DbUtils.StartTransaction
' Get selected records
Dim recList() As ${Table Control}Row = Me.GetSelectedRecordControls()
' Loop through each selected record
For Each rec As ${Table Control}Row In reclist
' If the field contains value "11111", then the deletion of the record is cancelled and an error message is displayed; otherwise, the
' selected record is deleted
If rec.${Field Value Control}.Text.Equals("11111") Then
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "Cannot delete record", "Cannot delete record with ${Field Value Control} = " + rec.${Field Value Control}.Text)
' Set the selection of the record to false so that the deletion of the record does not takes place.
rec.${Table Name}RecordRowSelection.Checked = False
End If
Next
Me.DeleteSelectedRecords(false)
Me.Page.CommitTransaction(sender)
Catch ex As Exception
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "BUTTON_CLICK_MESSAGE", ex.Message)
Me.Page.RollBackTransaction(sender)
Finally
DbUtils.CommitTransaction()
End Try
End Sub
|